package com.baidu.mapapi;

import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.ZoomControls;
import java.io.InputStream;
import java.util.List;

public class MapView extends ViewGroup
{
  public static final int DRAG_MODE_NONE = 1;
  public static final int DRAG_MODE_SCALE;
  private static int g = 0;
  d a = new d(this);
  a b = null;
  private GeoPoint c = new GeoPoint(0, 0);
  private int d = 12;
  private int e = 0;
  private int f = 0;
  private boolean h = false;
  private boolean i = false;
  private Message j = null;
  private Runnable k = null;
  private MapActivity l = null;
  private MapController m;
  private ZoomControls n = new ZoomControls(getContext());
  private ImageView o = new ImageView(getContext());
  private boolean p = false;

  public MapView(Context paramContext)
  {
    super(paramContext);
    a(paramContext);
  }

  public MapView(Context paramContext, AttributeSet paramAttributeSet)
  {
    super(paramContext, paramAttributeSet);
    a(paramContext);
  }

  public MapView(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
  {
    super(paramContext, paramAttributeSet, paramInt);
    a(paramContext);
  }

  private void a(View paramView, ViewGroup.LayoutParams paramLayoutParams)
  {
    paramView.measure(this.e, this.f);
    int i1 = paramLayoutParams.width;
    int i2 = paramLayoutParams.height;
    int i3;
    if (i1 == -1)
      i3 = this.e;
    while (true)
    {
      label46: int i4;
      int i5;
      if (i2 == -1)
      {
        i2 = this.f;
        if (!checkLayoutParams(paramLayoutParams))
          break label354;
        LayoutParams localLayoutParams = (LayoutParams)paramLayoutParams;
        i4 = localLayoutParams.x;
        i5 = localLayoutParams.y;
        if ((localLayoutParams.mode == 0) && (localLayoutParams.point != null))
        {
          Point localPoint = getProjection().toPixels(localLayoutParams.point, null);
          i4 = localPoint.x + localLayoutParams.x;
          i5 = localPoint.y + localLayoutParams.y;
        }
        switch (localLayoutParams.alignment)
        {
        case 3:
        case 48:
        case 51:
        default:
        case 80:
        case 5:
        case 81:
        case 17:
        case 1:
        case 16:
        }
      }
      while (true)
      {
        paramView.layout(i4, i5, i3 + i4, i2 + i5);
        return;
        if (i1 != -2)
          break label365;
        i3 = paramView.getMeasuredWidth();
        break;
        if (i2 != -2)
          break label46;
        i2 = paramView.getMeasuredHeight();
        break label46;
        i5 -= i2;
        continue;
        i4 -= i3;
        continue;
        i4 -= i3 / 2;
        i5 -= i2;
        continue;
        i4 -= i3 / 2;
        i5 -= i2 / 2;
        continue;
        i4 -= i3 / 2;
        continue;
        i5 -= i2 / 2;
      }
      label354: paramView.layout(0, 0, i3, i2);
      return;
      label365: i3 = i1;
    }
  }

  private boolean a(Context paramContext)
  {
    MapActivity localMapActivity = (MapActivity)paramContext;
    this.e = Mj.g;
    this.f = Mj.h;
    this.l = localMapActivity;
    g = 1 + g;
    return localMapActivity.a(this);
  }

  private void b(int paramInt)
  {
    this.d = paramInt;
    c();
  }

  void a(int paramInt1, int paramInt2)
  {
    Mj.MapProc(4354, paramInt1, paramInt2);
  }

  void a(GeoPoint paramGeoPoint)
  {
    this.c = paramGeoPoint;
    Mj.MapProc(4102, paramGeoPoint.getLongitudeE6(), paramGeoPoint.getLatitudeE6());
  }

  void a(GeoPoint paramGeoPoint, Message paramMessage, Runnable paramRunnable)
  {
    this.c = paramGeoPoint;
    Mj.MapProc(4353, paramGeoPoint.getLongitudeE6(), paramGeoPoint.getLatitudeE6());
    this.j = paramMessage;
    this.k = paramRunnable;
  }

  void a(boolean paramBoolean)
  {
    if (paramBoolean)
    {
      Mj.MapProc(4355, 1, 0);
      return;
    }
    Mj.MapProc(4355, 0, 0);
  }

  boolean a()
  {
    if (this.b == null)
      this.b = new a(getContext(), this);
    if (this.m == null)
      this.m = new MapController(this);
    if (this.b.getParent() == null)
      addView(this.b);
    if (this.n.getParent() == null)
    {
      this.n.setOnZoomOutClickListener(new View.OnClickListener()
      {
        public void onClick(View paramAnonymousView)
        {
          MapView.this.g();
        }
      });
      this.n.setOnZoomInClickListener(new View.OnClickListener()
      {
        public void onClick(View paramAnonymousView)
        {
          MapView.this.f();
        }
      });
      this.n.setFocusable(true);
      this.n.setVisibility(0);
      this.n.measure(0, 0);
    }
    if (this.o.getParent() == null);
    try
    {
      char[] arrayOfChar = { 108, 104 };
      int i1 = Mj.i;
      int i2 = 0;
      if (i1 <= 180);
      while (true)
      {
        String str = "baidumap_logo_" + arrayOfChar[i2] + ".png";
        InputStream localInputStream = this.l.getAssets().open(str);
        Bitmap localBitmap = BitmapFactory.decodeStream(localInputStream);
        localInputStream.close();
        if (localBitmap != null)
        {
          this.o.setImageBitmap(localBitmap);
          this.o.setVisibility(0);
          this.o.measure(0, 0);
          this.o.setScaleType(ImageView.ScaleType.FIT_CENTER);
          addView(this.o);
        }
        this.b.setFocusable(true);
        this.b.setFocusableInTouchMode(true);
        this.d = d();
        return true;
        i2 = 1;
      }
    }
    catch (Exception localException)
    {
      while (true)
      {
        Log.d("MapView()", "initMapView() error!");
        Log.d("MapView()", localException.getMessage());
      }
    }
  }

  boolean a(int paramInt)
  {
    this.d = getZoomLevel();
    if (paramInt < 3)
      paramInt = 3;
    while (true)
    {
      if (this.d != paramInt)
      {
        this.d = paramInt;
        Mj.MapProc(4098, paramInt, 1);
        c();
      }
      return true;
      if (paramInt > 18)
        paramInt = 18;
    }
  }

  boolean a(int paramInt1, int paramInt2, int paramInt3)
  {
    boolean bool = true;
    switch (paramInt1)
    {
    default:
      bool = false;
    case 9:
    case 505:
    case 8020:
    }
    do
    {
      do
      {
        do
          return bool;
        while (this.b == null);
        this.b.a = bool;
        invalidate();
        return bool;
        b(paramInt2);
        return bool;
        if (this.j == null)
          break;
      }
      while (this.j.getTarget() == null);
      this.j.getTarget().sendMessage(this.j);
      return bool;
    }
    while (this.k == null);
    this.k.run();
    return bool;
  }

  void b()
  {
    if (g <= 0);
    do
    {
      return;
      g = -1 + g;
    }
    while (g != 0);
    this.b.a();
    this.b = null;
  }

  void b(int paramInt1, int paramInt2)
  {
    Mj.MapProc(4103, paramInt1 + this.e / 2, paramInt2 + this.f / 2);
  }

  void c()
  {
    boolean bool1 = true;
    ZoomControls localZoomControls1 = this.n;
    boolean bool2;
    ZoomControls localZoomControls2;
    if (this.d > 3)
    {
      bool2 = bool1;
      localZoomControls1.setIsZoomOutEnabled(bool2);
      localZoomControls2 = this.n;
      if (this.d >= getMaxZoomLevel())
        break label51;
    }
    while (true)
    {
      localZoomControls2.setIsZoomInEnabled(bool1);
      return;
      bool2 = false;
      break;
      label51: bool1 = false;
    }
  }

  public boolean canCoverCenter()
  {
    Bundle localBundle = new Bundle();
    localBundle.putInt("act", 15010001);
    Mj.sendBundle(localBundle);
    return localBundle.getInt("r") != 0;
  }

  protected boolean checkLayoutParams(ViewGroup.LayoutParams paramLayoutParams)
  {
    return paramLayoutParams instanceof LayoutParams;
  }

  public void computeScroll()
  {
    super.computeScroll();
  }

  int d()
  {
    return Mj.getNewBundle(10030300, 0, 0).getInt("mapLevel");
  }

  public void displayZoomControls(boolean paramBoolean)
  {
    if ((!this.p) || (this.n.getParent() == null))
    {
      removeView(this.n);
      addView(this.n);
      this.p = true;
    }
    if (paramBoolean)
      requestChildFocus(this.n, this.n);
  }

  void e()
  {
    int i1 = getChildCount();
    int i2 = 0;
    if (i2 < i1)
    {
      View localView = super.getChildAt(i2);
      if ((localView == this.o) || (localView == this.n) || (localView == this.b));
      while (true)
      {
        i2++;
        break;
        ViewGroup.LayoutParams localLayoutParams = localView.getLayoutParams();
        if (((localLayoutParams instanceof LayoutParams)) && (((LayoutParams)localLayoutParams).mode == 0))
          a(localView, localLayoutParams);
      }
    }
  }

  boolean f()
  {
    if (this.d >= 18)
      return false;
    this.b.a(1, this.e / 2, this.f / 2);
    return true;
  }

  boolean g()
  {
    if (this.d <= 3)
      return false;
    this.b.a(-1, this.e / 2, this.f / 2);
    return true;
  }

  protected ViewGroup.LayoutParams generateDefaultLayoutParams()
  {
    return super.generateDefaultLayoutParams();
  }

  public ViewGroup.LayoutParams generateLayoutParams(AttributeSet paramAttributeSet)
  {
    return new LayoutParams(this.l, paramAttributeSet);
  }

  protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams paramLayoutParams)
  {
    return new LayoutParams(paramLayoutParams);
  }

  public MapController getController()
  {
    return this.m;
  }

  public int getLatitudeSpan()
  {
    d locald = (d)getProjection();
    GeoPoint localGeoPoint1 = locald.fromPixels(0, 0);
    GeoPoint localGeoPoint2 = locald.fromPixels(-1 + this.e, -1 + this.f);
    return Math.abs(localGeoPoint1.getLatitudeE6() - localGeoPoint2.getLatitudeE6());
  }

  public int getLongitudeSpan()
  {
    d locald = (d)getProjection();
    GeoPoint localGeoPoint = locald.fromPixels(0, 0);
    return Math.abs(locald.fromPixels(-1 + this.e, -1 + this.f).getLongitudeE6() - localGeoPoint.getLongitudeE6());
  }

  public GeoPoint getMapCenter()
  {
    Bundle localBundle = Mj.GetMapStatus();
    if (localBundle != null)
    {
      int i1 = localBundle.getInt("x");
      return new GeoPoint(localBundle.getInt("y"), i1);
    }
    return this.c;
  }

  public int getMaxZoomLevel()
  {
    return 18;
  }

  public int getMinZoomLevel()
  {
    return 3;
  }

  public final List<Overlay> getOverlays()
  {
    if (this.b == null)
      return null;
    return this.b.c();
  }

  public Projection getProjection()
  {
    return this.a;
  }

  @Deprecated
  public View getZoomControls()
  {
    return this.n;
  }

  public int getZoomLevel()
  {
    this.d = d();
    return this.d;
  }

  double h()
  {
    return Math.pow(2.0D, 18 - this.d);
  }

  public boolean isDoubleClickZooming()
  {
    return this.b.b();
  }

  public boolean isSatellite()
  {
    return this.i;
  }

  public boolean isStreetView()
  {
    return false;
  }

  public boolean isTraffic()
  {
    return this.h;
  }

  protected void onAttachedToWindow()
  {
    a();
    if (this.p)
      setBuiltInZoomControls(true);
    super.onAttachedToWindow();
  }

  protected void onDetachedFromWindow()
  {
    if ((this.p) && (this.n.getParent() != null))
      removeView(this.n);
    removeView(this.b);
    removeView(this.o);
    super.onDetachedFromWindow();
  }

  protected void onDraw(Canvas paramCanvas)
  {
    super.onDraw(paramCanvas);
  }

  public void onFocusChanged(boolean paramBoolean, int paramInt, Rect paramRect)
  {
    this.b.a(paramBoolean, paramInt, paramRect);
    super.onFocusChanged(paramBoolean, paramInt, paramRect);
  }

  public boolean onKeyDown(int paramInt, KeyEvent paramKeyEvent)
  {
    if (this.b.a(paramInt, paramKeyEvent))
      return true;
    return super.onKeyDown(paramInt, paramKeyEvent);
  }

  public boolean onKeyUp(int paramInt, KeyEvent paramKeyEvent)
  {
    if (this.b.b(paramInt, paramKeyEvent))
      return true;
    return super.onKeyUp(paramInt, paramKeyEvent);
  }

  protected void onLayout(boolean paramBoolean, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    this.e = (paramInt3 - paramInt1);
    this.f = (paramInt4 - paramInt2);
    this.b.setLayoutParams(new ViewGroup.LayoutParams(this.e, this.f));
    this.b.setVisibility(0);
    this.b.layout(0, 0, this.e, this.f);
    this.n.setLayoutParams(new ViewGroup.LayoutParams(this.e, this.f));
    this.n.setVisibility(0);
    this.n.measure(paramInt3 - paramInt1, paramInt4 - paramInt2);
    int i1 = this.n.getMeasuredWidth();
    int i2 = this.n.getMeasuredHeight();
    this.n.layout(paramInt3 - 10 - i1, paramInt4 - 5 - i2 - paramInt2, paramInt3 - 10, paramInt4 - 5 - paramInt2);
    this.o.setLayoutParams(new ViewGroup.LayoutParams(this.e, this.f));
    this.o.setVisibility(0);
    this.o.measure(paramInt3 - paramInt1, paramInt4 - paramInt2);
    int i3 = this.o.getMeasuredWidth();
    int i4 = this.o.getMeasuredHeight();
    int i6;
    label269: View localView;
    if (i2 > i4)
    {
      this.o.layout(10, paramInt4 - 5 - i2 - paramInt2, i3 + 10, paramInt4 - 5 - paramInt2);
      int i5 = getChildCount();
      i6 = 0;
      if (i6 >= i5)
        return;
      localView = super.getChildAt(i6);
      if ((localView != this.o) && (localView != this.n) && (localView != this.b))
        break label324;
    }
    while (true)
    {
      i6++;
      break label269;
      i2 = i4;
      break;
      label324: a(localView, localView.getLayoutParams());
    }
  }

  protected void onMeasure(int paramInt1, int paramInt2)
  {
    super.onMeasure(paramInt1, paramInt2);
  }

  public void onRestoreInstanceState(Bundle paramBundle)
  {
    int i1 = paramBundle.getInt("lat");
    int i2 = paramBundle.getInt("lon");
    if ((i1 != 0) && (i2 != 0))
      a(new GeoPoint(i1, i2));
    int i3 = paramBundle.getInt("zoom");
    if (i3 != 0)
      a(i3);
    setTraffic(paramBundle.getBoolean("traffic"));
  }

  public void onSaveInstanceState(Bundle paramBundle)
  {
    GeoPoint localGeoPoint = getMapCenter();
    paramBundle.putInt("lat", localGeoPoint.getLatitudeE6());
    paramBundle.putInt("lon", localGeoPoint.getLongitudeE6());
    paramBundle.putInt("zoom", getZoomLevel());
    paramBundle.putBoolean("traffic", isTraffic());
  }

  protected void onSizeChanged(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    super.onSizeChanged(paramInt1, paramInt2, paramInt3, paramInt4);
    this.e = paramInt1;
    this.f = paramInt2;
  }

  public boolean onTouchEvent(MotionEvent paramMotionEvent)
  {
    if ((this.b != null) && (this.b.a(paramMotionEvent)))
      return true;
    return super.onTouchEvent(paramMotionEvent);
  }

  public boolean onTrackballEvent(MotionEvent paramMotionEvent)
  {
    if (this.b.b(paramMotionEvent))
      return true;
    return super.onTrackballEvent(paramMotionEvent);
  }

  public void onWindowFocusChanged(boolean paramBoolean)
  {
    super.onWindowFocusChanged(paramBoolean);
  }

  public void preLoad()
  {
  }

  public void regMapViewListener(BMapManager paramBMapManager, MKMapViewListener paramMKMapViewListener)
  {
    if ((paramBMapManager == null) || (paramBMapManager.a == null))
      return;
    paramBMapManager.a.a(paramMKMapViewListener);
  }

  public void setBuiltInZoomControls(boolean paramBoolean)
  {
    if (paramBoolean)
    {
      if ((this.p) || (this.n.getParent() != null))
        removeView(this.n);
      addView(this.n);
      this.p = true;
      return;
    }
    removeView(this.n);
  }

  public void setDoubleClickZooming(boolean paramBoolean)
  {
    this.b.a(paramBoolean);
  }

  public void setDragMode(int paramInt)
  {
    this.b.a(paramInt);
  }

  public void setDrawOverlayWhenZooming(boolean paramBoolean)
  {
    this.b.b(paramBoolean);
  }

  public void setReticleDrawMode(a parama)
  {
    throw new RuntimeException("this feature is not implemented!!");
  }

  public void setSatellite(boolean paramBoolean)
  {
    Bundle localBundle = new Bundle();
    localBundle.putInt("act", 1001);
    localBundle.putInt("opt", 10020803);
    if (paramBoolean)
      localBundle.putInt("on", 1);
    while (true)
    {
      Mj.sendBundle(localBundle);
      this.i = paramBoolean;
      return;
      localBundle.putInt("on", 0);
    }
  }

  public void setStreetView(boolean paramBoolean)
  {
    throw new RuntimeException("this feature is not implemented!!");
  }

  public void setTraffic(boolean paramBoolean)
  {
    Bundle localBundle = new Bundle();
    localBundle.putInt("act", 1001);
    localBundle.putInt("opt", 10020400);
    if (paramBoolean)
      localBundle.putInt("on", 1);
    while (true)
    {
      Mj.sendBundle(localBundle);
      this.h = paramBoolean;
      return;
      localBundle.putInt("on", 0);
    }
  }

  public static class LayoutParams extends ViewGroup.LayoutParams
  {
    public static final int BOTTOM = 80;
    public static final int BOTTOM_CENTER = 81;
    public static final int CENTER = 17;
    public static final int CENTER_HORIZONTAL = 1;
    public static final int CENTER_VERTICAL = 16;
    public static final int LEFT = 3;
    public static final int MODE_MAP = 0;
    public static final int MODE_VIEW = 1;
    public static final int RIGHT = 5;
    public static final int TOP = 48;
    public static final int TOP_LEFT = 51;
    public int alignment = 51;
    public int mode = 1;
    public GeoPoint point = null;
    public int x = 0;
    public int y = 0;

    public LayoutParams(int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5)
    {
      super(paramInt2);
      this.mode = 1;
      this.x = paramInt3;
      this.y = paramInt4;
      this.alignment = paramInt5;
    }

    public LayoutParams(int paramInt1, int paramInt2, GeoPoint paramGeoPoint, int paramInt3)
    {
      this(paramInt1, paramInt2, paramGeoPoint, 0, 0, paramInt3);
    }

    public LayoutParams(int paramInt1, int paramInt2, GeoPoint paramGeoPoint, int paramInt3, int paramInt4, int paramInt5)
    {
      super(paramInt2);
      this.mode = 0;
      this.point = paramGeoPoint;
      this.x = paramInt3;
      this.y = paramInt4;
      this.alignment = paramInt5;
    }

    public LayoutParams(Context paramContext, AttributeSet paramAttributeSet)
    {
      super(paramAttributeSet);
    }

    public LayoutParams(ViewGroup.LayoutParams paramLayoutParams)
    {
      super();
    }
  }

  static enum a
  {
    static
    {
      a[] arrayOfa = new a[3];
      arrayOfa[0] = a;
      arrayOfa[1] = b;
      arrayOfa[2] = c;
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.baidu.mapapi.MapView
 * JD-Core Version:    0.6.2
 */